﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace BBCore.Core.Services
{
    public class GetModelClassName
    {
        /// <summary>
        /// 获取当前程序集的类名
        /// </summary>
        /// <param name="_namespace">例如:BBCore.Core.Models.Samples</param>
        /// <returns></returns>
        public IEnumerable<Type> GetEntityTypes(string _namespace)
        {
            return Assembly.GetExecutingAssembly().GetTypes()
                            .Where
                            (t => t.IsClass
                            && !t.IsAbstract
                            && t.Namespace == _namespace
                            && t.DeclaringType == null //只获取顶部类
                            && !t.Name.EndsWith("Validator") //排除验证类
                            );
        }
    }
}
